package com.dlb.andorid.presenter;

import com.dlb.andorid.XAPI;
import com.dlb.andorid.XContract;
import com.dlb.andorid.XPresenter;
import com.dlb.andorid.XServerMsg;
import com.dlb.andorid.bean.ProductBean;
import com.dlb.andorid.bean.ServerResult;

import java.util.HashMap;
import java.util.List;

public class JrbkPresenter extends XPresenter {

	XContract.IJrbxView iView;

	public JrbkPresenter(XContract.IJrbxView iView) {
		super(iView);
		this.iView = iView;
	}

	public void get(long merchant_id) {
		mModel.getJrbk(merchant_id);
	}

	public void addCar(long id, String userId, int num, long typeId, float price) {
		mModel.addCar(id, userId, num, typeId, price);
	}

	@Override
	public void onDataSuccess(int vocational_id, HashMap<String, Object> exData, Object data) {
		super.onDataSuccess(vocational_id, exData, data);
		switch (vocational_id) {
			case XAPI.GET_JRBK_VOCATIONAL_ID:
				iView.getJrbkSuccess(((XServerMsg<List<ProductBean>>) data).getData());
				break;
			case XAPI.ADD_CAR_VOCATIONAL_ID:
				iView.addCarSuccess(((XServerMsg<ServerResult>) data).getData());
				break;
		}

	}
}
